package com.zx.kitchen.index.common.mvp.model;

import android.app.ProgressDialog;
import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.loopj.android.http.RequestParams;
import com.zx.kitchen.index.common.base.Contants;
import com.zx.kitchen.index.common.entity.GoodDetailListBean;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.utils.HttpUtils;
import com.zx.kitchen.index.common.utils.PreferenceUtil;

/**
 * Created by Administrator on 2017/3/20.
 */

public class BusinessGoodsDetailModelImpl implements GoodsDetailModel {
    @Override
    public void getFromNet(int requestCode, Context context, String start_time, String end_time, String goods_id, String type, OnResultListener listener, ProgressDialog progressDialog) {
        RequestParams params = new RequestParams();
        params.put("user_data", PreferenceUtil.getStringData(context, Contants.spToken));
        params.put("start_time", start_time);
        params.put("end_time", end_time);
        params.put("goods_id", goods_id);
        params.put("type", type);
        HttpUtils.post(context, Contants.BUSINESSREPORT_GOODSDETAIL_URL, params, requestCode, listener, progressDialog);
    }

    @Override
    public GoodDetailListBean asyncJson(String str) {
        return JSON.parseObject(str,new TypeReference<GoodDetailListBean>(){});
    }
}
